package spider.util;

import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;

import java.net.URI;

/**
 * created by yb
 * on 2017/8/12.
 **/
public class NovelSpiderHttpGet extends HttpGet{
    public NovelSpiderHttpGet() {
    }

    public NovelSpiderHttpGet(URI uri) {
        super(uri);
    }

    public NovelSpiderHttpGet(String uri) {
        super(uri);
        setDefaultConfig();
    }

    /**
     * 配置超时时间
     */
    private void setDefaultConfig(){
        this.setConfig(RequestConfig.custom()
                .setSocketTimeout(2*1000)
                .setConnectTimeout(10*1000)// 链接超时,读取超时
                .setConnectionRequestTimeout(10*1000).build());  //10 * 1000是10秒
        this.setHeader("User-Agent","NovelSpider");
    }
}
